﻿@model IEnumerable<WebApp.Models.Message>
@{
    ViewBag.Title = "日志信息";

}
<!-- MAIN CONTENT -->
<div id="content">
        <div class="row">
            <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                <h1 class="page-title txt-color-blueDark">
                    <i class="fa fa-list-alt fa-fw "></i>
                    系统管理
                    <span>
                        >
                        日志消息
                    </span>
                </h1>
            </div>
            <div class="col-xs-12 col-sm-5 col-md-5 col-lg-8">

            </div>
        </div>

        <!-- widget grid -->
        <section id="widget-grid" class="">

            <!-- row -->
            <div class="row">
                <article class="col-xs-6 col-sm-3 col-md-3 col-lg-3">

                    <!-- Widget ID (each widget will need unique ID)-->
                    <div class="jarviswidget jarviswidget-color-red" id="wid-id-0" data-widget-editbutton="false" data-widget-deletebutton="false" data-widget-fullscreenbutton="false">
                        <!-- widget options:
                            usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                            data-widget-colorbutton="false"
                            data-widget-editbutton="false"
                            data-widget-togglebutton="false"
                            data-widget-deletebutton="false"
                            data-widget-fullscreenbutton="false"
                            data-widget-custombutton="false"
                            data-widget-collapsed="true"
                            data-widget-sortable="false"

                        -->
                        <header>
                            <span class="widget-icon"> <i class="fa fa-warning"></i> </span>
                            <h2 class="font-md"><strong>新增异常</strong> <i>new</i></h2>

                        </header>

                        <!-- widget div-->
                        <div>

                            <!-- widget edit box -->
                            <div class="jarviswidget-editbox">
                                <!-- This area used as dropdown edit box -->

                            </div>
                            <!-- end widget edit box -->
                            <!-- widget content -->
                            <div class="widget-body">

                                <h1 class=" "> @ViewBag.TotalNewError.ToString("N0") </h1>
                                <small>新增异常</small>

                            </div>
                            <!-- end widget content -->

                        </div>
                        <!-- end widget div -->

                    </div>



                </article>
                <article class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <!-- Widget ID (each widget will need unique ID)-->
                    <div class="jarviswidget jarviswidget-color-red" id="wid-id-1" data-widget-editbutton="false" data-widget-deletebutton="false" data-widget-fullscreenbutton="false">
                        <!-- widget options:
                            usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                            data-widget-colorbutton="false"
                            data-widget-editbutton="false"
                            data-widget-togglebutton="false"
                            data-widget-deletebutton="false"
                            data-widget-fullscreenbutton="false"
                            data-widget-custombutton="false"
                            data-widget-collapsed="true"
                            data-widget-sortable="false"

                        -->
                        <header>
                            <span class="widget-icon"> <i class="fa fa-warning"></i> </span>
                            <h2 class="font-md"><strong>系统异常</strong> <i>all</i></h2>

                        </header>

                        <!-- widget div-->
                        <div>

                            <!-- widget edit box -->
                            <div class="jarviswidget-editbox">
                                <!-- This area used as dropdown edit box -->

                            </div>
                            <!-- end widget edit box -->
                            <!-- widget content -->
                            <div class="widget-body">

                                <h1 class=" "> @ViewBag.TotalSysError.ToString("N0")</h1>
                                <small>系统异常</small>

                            </div>
                            <!-- end widget content -->

                        </div>
                        <!-- end widget div -->

                    </div>


                </article>

                <article class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <!-- Widget ID (each widget will need unique ID)-->
                    <div class="jarviswidget jarviswidget-color-red" id="wid-id-2" data-widget-editbutton="false" data-widget-deletebutton="false" data-widget-fullscreenbutton="false">
                        <!-- widget options:
                            usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                            data-widget-colorbutton="false"
                            data-widget-editbutton="false"
                            data-widget-togglebutton="false"
                            data-widget-deletebutton="false"
                            data-widget-fullscreenbutton="false"
                            data-widget-custombutton="false"
                            data-widget-collapsed="true"
                            data-widget-sortable="false"

                        -->
                        <header>
                            <span class="widget-icon"> <i class="fa fa-warning"></i> </span>
                            <h2 class="font-md"><strong>操作异常</strong> <i>all</i></h2>

                        </header>

                        <!-- widget div-->
                        <div>

                            <!-- widget edit box -->
                            <div class="jarviswidget-editbox">
                                <!-- This area used as dropdown edit box -->

                            </div>
                            <!-- end widget edit box -->
                            <!-- widget content -->
                            <div class="widget-body">

                                <h1 class=" "> @ViewBag.TotalOpError.ToString("N0")</h1>
                                <small>操作异常</small>

                            </div>
                            <!-- end widget content -->

                        </div>
                        <!-- end widget div -->

                    </div>


                </article>

                <article class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
                    <!-- Widget ID (each widget will need unique ID)-->
                    <div class="jarviswidget jarviswidget-color-red" id="wid-id-3" data-widget-editbutton="false" data-widget-deletebutton="false" data-widget-fullscreenbutton="false">
                        <!-- widget options:
                            usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                            data-widget-colorbutton="false"
                            data-widget-editbutton="false"
                            data-widget-togglebutton="false"
                            data-widget-deletebutton="false"
                            data-widget-fullscreenbutton="false"
                            data-widget-custombutton="false"
                            data-widget-collapsed="true"
                            data-widget-sortable="false"

                        -->
                        <header>
                            <span class="widget-icon"> <i class="fa fa-warning"></i> </span>
                            <h2 class="font-md"><strong>接口异常</strong> <i>all</i></h2>

                        </header>

                        <!-- widget div-->
                        <div>

                            <!-- widget edit box -->
                            <div class="jarviswidget-editbox">
                                <!-- This area used as dropdown edit box -->

                            </div>
                            <!-- end widget edit box -->
                            <!-- widget content -->
                            <div class="widget-body">

                                <h1 class=" "> @ViewBag.TotalInterfaceError.ToString("N0")</h1>
                                <small>接口异常</small>

                            </div>
                            <!-- end widget content -->

                        </div>
                        <!-- end widget div -->

                    </div>


                </article>

            </div>

            <div class="row">

                <div class="col-sm-12">
                    <div class="well">
                        <h1>系统日志</h1>
                        <div class="table-responsive">
                            <table id="messages_datagrid" >
                            </table>

                        </div>
                    </div>
                </div>
            </div>

</section>






<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog  modal-lg">
                <div class="modal-content animated bounceInRight">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h5 class="modal-title">日志</h5>

                    </div>
                    <div class="modal-body">
                        <div class="alert alert-success" role="alert" id="alert-content">
                            <h4 class="alert-heading" id="title-method"></h4>
                            <p id="msg-content"></p>

                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-white" data-dismiss="modal">Close</button>

                    </div>
                </div>
            </div>
</div>


</div>
<!-- END MAIN CONTENT -->
<!-- end file upload partial view -->
@section Scripts {
<script type="text/javascript">
    //上传导入参数设定
    const entityname = "Message";
            //执行Excel到处下载
            function exportexcel() {
                var filterRules = JSON.stringify($dg.datagrid("options").filterRules);
                //console.log(filterRules);
                $.messager.progress({ title: "正在执行导出！" });
                var formData = new FormData();
                formData.append("filterRules", filterRules);
                formData.append("sort", "Id");
                formData.append("order", "asc");
                $.postDownload("/Messages/ExportExcel", formData, function (fileName) {
                    $.messager.progress("close");
                    console.log(fileName);
                })
            }
            //datagrid 增删改查操作
            var $dg = $("#messages_datagrid");
            var editIndex = undefined;
            function reload() {
                $dg.datagrid("reload");
            }
  function onClickRow(index, row) {
    console.log(row, index);
    if (row.IsNew == 0) {
      $.get(`/Messages/SetMessageState?id=${row.Id}`).done(res => {
        if (res.success) {
          console.log(res);
          row.IsNew = 1;
          row.IsNotification = 1;
          $dg.datagrid('updateRow', {
            index: index,
            row: {
              IsNew: 1,
              IsNotification:1
            }
          });
          $dg.datagrid('refreshRow', index);
          
        }

      })
    }
                $('#myModal').modal();
                $('#title-method').text(row.Method);
                $('#msg-content').text(row.Content);
                $('#alert-content').removeClass();
                if (row.Type === 0) {
                    $('#alert-content').addClass('alert alert-success');
                } else if (row.Type === 0) {
                    $('#alert-content').addClass('alert alert-danger');
                } else {
                    $('#alert-content').addClass('alert alert-warning');
                }


            }
            //datagrid 开启行赛选功能
    $(function () {

        $dg.datagrid({
            rownumbers: true,
            checkOnSelect: true,
            selectOnCheck: true,
            idField: 'Id',
            sortName: 'Id',
            sortOrder: 'desc',
            remoteFilter: true,
            singleSelect: true,
            url: '/Messages/GetData',
            method: 'get',
            onClickRow: onClickRow,
            onSelect: onSelect,
            pagination: 'true',
            columns: [[
                { field: 'Group', title: '@Html.DisplayNameFor(model => model.Group)', width: 100, align: 'right', sortable: true, resizable: true, formatter: messagegroupformatter },
               
  { field: 'Method', width: 120, sortable: true, resizable: true, title: '@Html.DisplayNameFor(model => model.Method)' },
   { field: 'ExtensionKey1', title: '@Html.DisplayNameFor(model => model.ExtensionKey1)',width:140 ,sortable:true,resizable:true  },
              { field: 'Type', title: '@Html.DisplayNameFor(model => model.Type)', width: 100, align: 'right', sortable: true, resizable: true, formatter: messagetypeformatter },
                
                { field:'Content' ,width:360 ,sortable:true,resizable:true,title:'@Html.DisplayNameFor(model => model.Content)' },
                { field: 'User', width: 140, sortable: true, resizable: true, title: '@Html.DisplayNameFor(model => model.User)' },
                { field: 'IsNew', width: 100, align: 'right', sortable: true, resizable: true, formatter: isnewformatter, title: '@Html.DisplayNameFor(model => model.IsNew)' },
              { field: 'Tags', width: 140, sortable: true, resizable: true, title: '@Html.DisplayNameFor(model => model.Tags)' },
                { field: 'ExtensionKey2', width: 140, sortable: true, resizable: true, title: '@Html.DisplayNameFor(model => model.ExtensionKey2)' },
              { field: 'Code', title: '@Html.DisplayNameFor(model => model.Code)', width: 140, sortable: true, resizable: true },
                { field: 'Created', width: 160, align: 'right', sortable: true, resizable: true, formatter: datetimeformatter, title: '@Html.DisplayNameFor(model => model.Created)' },
                
                
                { field: 'IsNotification', width: 100, align: 'right', sortable: true, resizable: true, formatter: isnoticeformatter, title: '@Html.DisplayNameFor(model => model.IsNotification)' }
            ]]

        });
        $dg.datagrid("enableFilter", [
            {
                field: 'Group',
                type: 'messagegroupfilter',

            },
            {
                field: 'Type',
                type: 'messagetypefilter',

            },
            {
                field: 'IsNew',
                type: 'isnewfilter',

            },
            {
                field: 'IsNotification',
                type: 'isnoticefilter',

            },
            {
                field: "Created",
                type: "datebox",
                options: {
                    onChange: function (value) {
                        if (value == "") {
                            $dg.datagrid("removeFilterRule", "Created");
                        } else {
                            $dg.datagrid("addFilterRule", {
                                field: "Created",
                                op: "equal",
                                value: value
                            });
                        }
                        $dg.datagrid("doFilter");
                    }
                }
            }
        ]);

        $dg.datagrid('removeFilterRule', 'IsNew');
        $dg.datagrid('addFilterRule', {
            field: 'IsNew',
            op: 'equal',
            value: '0'
        });
    });


            //-----------------------------------------------------
            //datagrid onSelect
            //-----------------------------------------------------
    function onSelect(index, row) {
        //console.log(index, row);
    }
</script>
}
